package com.nearby.android;

import com.nearby.android.unitl.ShakeDetector;
import com.nearby.android.unitl.ShakeDetector.OnShakeListener;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

public class ShakeTest extends Activity implements OnShakeListener{
	private ShakeDetector shake;
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.shaketest);
		shake = new ShakeDetector(this);
	}
	@Override
	protected void onResume(){
		super.onResume();
		shake.registerOnShakeListener(this);
		shake.start();
	}
	@Override
	protected void onStop(){
		super.onStop();
		shake.unregisterOnShakeListener(this);
		shake.stop();
	}
	@Override
	public void onShake() {
		Toast.makeText(this, "发生了摇晃事件了", Toast.LENGTH_LONG).show();

		shake.stop();
	}
}
